﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Httlgd.DataCenter.Services.Core.Common;
using System.Runtime.Serialization;

namespace Httlgd.DataCenter.Services.Core
{
    [DataContract]
    public abstract class BusinessEntityBase : DataTransferObjectBase
    {
        /// <summary>
        /// Gets or sets the key of the entity
        /// </summary>
        public abstract object Key
        {
            get;
            set;
        }

        [DataMember]
        public DateTime LastUpdateDate { get; set; }

        [DataMember]
        public DateTime CreateDate { get; set; }

        /// <summary>
        /// Gets a value indicating whether this business entity has key specified.
        /// </summary>
        public virtual bool HasKey
        {
            get
            {
                if (this.Key == null)
                {
                    return false;
                }

                return this.Key.ToString().ToInt() > 0 || string.IsNullOrEmpty(this.Key.ToString());
            }
        }
    }
}
